import request from '@/utils/request'
import { remove } from 'nprogress'

const api_name = '/admin/system/sysRole'

export default {
    /**
     * 获取角色列表 带搜素
     */
    getPageList(page, limit, searchObj) {
        if (typeof page !== 'number' || typeof limit !== 'number') {
            throw new Error('page 和 limit 必须为数字类型')
        }
        return request({
            url: `${api_name}/${page}/${limit}`,
            method: 'get',
            params: searchObj
        })

    },
    // 删除
    removeById(id) {
        return request({
            url: `${api_name}/remove/${id}`,
            method: 'delete',
        })
    },
    // 修改
    update(role) {
        return request({
            url: `${api_name}/update`,
            method: 'post',
            data: role
        })
    },
    // 添加
    save(role) {
        return request({
            url: `${api_name}/save`,
            method: 'put',
            data: role
        })
    },
    // 单个查询
    getById(id) {
        return request({
            url: `${api_name}/getById/${id}`,
            method: 'get',
        })
    },
    // 批量删除
    batchRemove(idList) {
        return request({
            url: `${api_name}/batchRemove`,
            method: 'delete',
            data: idList
        })
    },
}